package afinadroid.salesforce.bbdd;

import java.io.File;

import afinadroid.salesforce.test401.utils.TestApplication;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class AccesoBD {

	private Context context;
	private SQLiteDatabase bdRead;
	private SQLiteDatabase bdWrite;
	BbddSalesforce testBD;
	private final String BDNAME = "BDTest";
	
	public AccesoBD(Context context){
		this.context = context;
		testBD = new BbddSalesforce(context, BDNAME, null, TestApplication.DDBB_VERSION);
	}
		
	public void abrirBD(){ 
		this.bdRead = testBD.getReadableDatabase();

	}
	
	public void cerrarBD(SQLiteDatabase bd){
		bd.close();
	}
	

	
	public Cursor ejecutarSelect(String sentencia){
		return bdRead.rawQuery(sentencia, null);
	}
	
	private boolean doesDatabaseExist(Context context, String dbName) {
	    File dbFile = context.getDatabasePath(dbName);
	    return dbFile.exists();
	}
	
}
